/*    */ package com.qmsk.business.info.shop.controller;
/*    */ 
/*    */ import com.qmsk.business.info.shop.dao.ShopUserDAO;
/*    */ import com.qmsk.session.UserSessionInfo;
/*    */ import com.utils.gson.out.GsonEbRst;
/*    */ import com.utils.jdbc.connection.DbConnection;
/*    */ import com.utils.web.RequestUtils;
/*    */ import com.utils.web.ResponseUtils;
/*    */ import java.sql.SQLException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import org.apache.log4j.Logger;
/*    */ import org.springframework.beans.factory.annotation.Autowired;
/*    */ import org.springframework.stereotype.Controller;
/*    */ import org.springframework.transaction.annotation.Transactional;
/*    */ import org.springframework.web.bind.annotation.PathVariable;
/*    */ import org.springframework.web.bind.annotation.RequestMapping;
/*    */ 
/*    */ @Controller
/*    */ @RequestMapping({"/shopUser"})
/*    */ public class ShopUserController
/*    */ {
/* 27 */   private static final Logger logger = Logger.getLogger(ShopUserController.class);
/*    */ 
/*    */   @Autowired
/*    */   private ShopUserDAO dao;
/*    */ 
/*    */   @RequestMapping(value={"find/userId/all/{userId}"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getListOfUserIdAll(HttpServletRequest request, HttpServletResponse response, @PathVariable("userId") String userId)
/*    */   {
/*    */     try {
/* 36 */       GsonEbRst gsonEbRst = this.dao.getGsonShopListOfUserId(userId);
/* 37 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 39 */       logger.error(e);
/* 40 */       ResponseUtils.setErrorMsgResponse(
/* 41 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @RequestMapping(value={"find/sessionUserId"}, method={org.springframework.web.bind.annotation.RequestMethod.GET})
/*    */   public void getShopListOfSessionUserId(HttpServletRequest request, HttpServletResponse response) {
/* 47 */     String userId = UserSessionInfo.getUserIdOfSession(request);
/*    */     try {
/* 49 */       GsonEbRst gsonEbRst = this.dao.getGsonShopListOfUserId(userId);
/* 50 */       ResponseUtils.setResponseResult(gsonEbRst, response);
/*    */     } catch (SQLException e) {
/* 52 */       logger.error(e);
/* 53 */       ResponseUtils.setErrorMsgResponse(
/* 54 */         RequestUtils.getFindDataErrorMessage(request), response);
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"insert/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void insertList(HttpServletRequest request, HttpServletResponse response) {
/* 61 */     String sJson = RequestUtils.getString(request, "data");
/* 62 */     int nUpdates = -1;
/*    */     try {
/* 64 */       this.dao.deleteListPk(sJson);
/* 65 */       nUpdates = this.dao.insertList(sJson);
/* 66 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 67 */         RequestUtils.getSqlInsertDataErrorMessage(request), 
/* 68 */         response);
/*    */     } catch (SQLException e) {
/* 70 */       logger.error(e);
/* 71 */       ResponseUtils.setErrorMsgResponse(
/* 72 */         RequestUtils.getSqlInsertDataErrorMessage(request) + ":" + 
/* 73 */         e.getMessage(), response);
/*    */     } finally {
/* 75 */       if (nUpdates <= -1)
/* 76 */         DbConnection.rollback();
/*    */       else
/* 78 */         DbConnection.commit();
/*    */     }
/*    */   }
/*    */ 
/*    */   @Transactional
/*    */   @RequestMapping(value={"delete/List"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
/*    */   public void deleteList(HttpServletRequest request, HttpServletResponse response)
/*    */   {
/* 86 */     int nUpdates = -1;
/* 87 */     String sJson = RequestUtils.getStringOfId(request);
/*    */     try {
/* 89 */       nUpdates = this.dao.deleteList(sJson);
/* 90 */       ResponseUtils.setSqlResultResponse(nUpdates, 
/* 91 */         RequestUtils.getSqlDeleteDataErrorMessage(request), 
/* 92 */         response);
/*    */     } catch (SQLException e) {
/* 94 */       ResponseUtils.setErrorMsgResponse(
/* 95 */         RequestUtils.getSqlDeleteDataErrorMessage(request) + ":" + 
/* 96 */         e.getMessage(), response);
/* 97 */       logger.error(e);
/*    */     } finally {
/* 99 */       if (nUpdates <= -1)
/* 100 */         DbConnection.rollback();
/*    */       else
/* 102 */         DbConnection.commit();
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\Users\Administrator\Desktop\新建文件夹\WEB-INF\classes\
 * Qualified Name:     com.qmsk.business.info.shop.controller.ShopUserController
 * JD-Core Version:    0.5.3
 */